
******************************************************
***************** TABLE A.7 *******************
use "${ddata}cleaned_data_wACSweight.dta", clear

capture program drop store_reg
program define store_reg, rclass

	matrix B = e(b)
	matrix V = e(V)

	local b = string(B[1,1],  "%8.2fc")
	local se = "(" + string(sqrt(V[1,1]), "%8.2fc") + ")"
	local p = 2*ttail(e(df_r),abs(B[1,1]/sqrt(V[1,1])))
	local star=""
	if `p' >.05 & `p' <=.10 { 	
		local star = "$ds^{*}$ds"
	}
	if `p' >.01 & `p' <=.05 { 	
		local star = "$ds^{**}$ds"
	}
	if `p' <=.01 {	
		local star = "$ds^{***}$ds" 
	}

	local p_val=string(`p', "%10.3fc")

	return local beta = "`b'"
	return local se = "`se'"
	return local star = "`star'"
	return local pvalue= "`p_val'"

end

global demographics white age male college married working_ft child_under_6 child_under_18 lincome i.sce i.current_censusdiv

xi: reg donation_fo treatment [aw=weight_ACS], 			 robust 
store_reg
local fo_all = "`r(beta)'`r(star)'"
local fo_all_se = "`r(se)'"
local fo_all_obs = e(N)


xi: reg donation_fo treatment $demographics [aw=weight_ACS] , robust
store_reg 
local fo_control_all = "`r(beta)'`r(star)'"
local fo_control_all_se = "`r(se)'"
local fo_control_all_obs = e(N)

xi: reg donation_fo treatment if male==0 [aw=weight_ACS], robust //2-1
store_reg 
local fo_female = "`r(beta)'`r(star)'"
local fo_female_se = "`r(se)'"
local fo_female_obs = e(N)

xi: reg donation_fo treatment $demographics   if male==0 [aw=weight_ACS], 				 robust //2-2
store_reg 
local fo_control_female = "`r(beta)'`r(star)'"
local fo_control_female_se = "`r(se)'"
local fo_control_female_obs = e(N)

xi: reg donation_fo treatment 				   if male==1 [aw=weight_ACS]			   , robust //3-2
store_reg 
local fo_male = "`r(beta)'`r(star)'"
local fo_male_se = "`r(se)'"
local fo_male_obs = e(N)

xi: reg donation_fo treatment $demographics   if male==1 [aw=weight_ACS], 				 robust //3-2
store_reg 
local fo_control_male = "`r(beta)'`r(star)'"
local fo_control_male_se = "`r(se)'"
local fo_control_male_obs = e(N)

xi: reg donation_so treatment 				   				 [aw=weight_ACS], 			 robust //1-3
store_reg 
local so_all = "`r(beta)'`r(star)'"
local so_all_se = "`r(se)'"
local so_all_obs = e(N)

xi: reg donation_so treatment $demographics  [aw=weight_ACS], 				   			 robust //1-4
store_reg 
local so_control_all = "`r(beta)'`r(star)'"
local so_control_all_se = "`r(se)'"
local so_control_all_obs = e(N)

xi: reg donation_so treatment 				   if male==0 [aw=weight_ACS] 			   , robust //2-3
store_reg 
local so_female = "`r(beta)'`r(star)'"
local so_female_se = "`r(se)'"
local so_female_obs = e(N)

xi: reg donation_so treatment $demographics   if male==0 [aw=weight_ACS], 				 robust //2-4
store_reg 
local so_control_female = "`r(beta)'`r(star)'"
local so_control_female_se = "`r(se)'"
local so_control_female_obs = e(N)

xi: reg donation_so treatment 				   if male==1 [aw=weight_ACS]			   , robust //3-3
store_reg 
local so_male = "`r(beta)'`r(star)'"
local so_male_se = "`r(se)'"
local so_male_obs = e(N)

xi: reg donation_so treatment $demographics   if male==1 [aw=weight_ACS], 				 robust //3-4
store_reg 
local so_control_male = "`r(beta)'`r(star)'"
local so_control_male_se = "`r(se)'"
local so_control_male_obs = e(N)


texdoc init "${o}TableA7_ACSweighted_final.tex", replace force

tex \begin{tabular}{lcccccccc} 
tex \toprule

tex & \multicolumn{5}{c}{Dep. Var: Share Donated} & & \\
tex \cmidrule{2-6}
tex & \multicolumn{2}{c}{First Order Beliefs} &  & \multicolumn{2}{c}{Second Order Beliefs} & & \multicolumn{1}{c}{Observations} \\

tex  & (1) & (2) &  & (3) & (4) & & \\
tex \textbf{All} & &  & & & & & \\\
tex Treatment & `fo_all' & `fo_control_all' &  & `so_all' & `so_control_all' & & `fo_all_obs' \\
tex & `fo_all_se' & `fo_control_all_se' &  & `so_all_se' & `so_control_all_se' & &  \\
tex \\

tex \textbf{Women} & & & & & & & \\
tex Treatment & `fo_female' & `fo_control_female' &  & `so_female' & `so_control_female' & & `fo_female_obs' \\
tex & `fo_female_se' & `fo_control_female_se' &  & `so_female_se' & `so_control_female_se' & &  \\
tex \\

tex \textbf{Men} & & & & & & & \\
tex Treatment & `fo_male' & `fo_control_male' &  & `so_male' & `so_control_male' & & `fo_male_obs' \\
tex & `fo_male_se' & `fo_control_male_se' &  & `so_male_se' & `so_control_male_se' & &  \\
tex \\

tex \midrule
tex \textbf{Controls} & & Yes  & & & Yes & & \\

tex \bottomrule
tex \end{tabular}

texdoc close


